﻿using Library.Core.Domain.Specification;
using Synthesize.BaseSet.Domain.Aggregation.Entity.Authority;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text;

namespace Synthesize.BaseSet.Domain.Specifications.Authority.Post
{
    /// <summary>
    /// 岗位查询条件拼装
    /// </summary>
    public class GetPostListSpceification : ISpecification<PostInfoEntity>
    {

        private readonly string _name;

        public GetPostListSpceification(string name)
        {
            _name = name;
        }
        public Expression<Func<PostInfoEntity, bool>> SatisfiedBy()
        {
            Specification<PostInfoEntity> spec = new TrueSpecification<PostInfoEntity>();

            if (!string.IsNullOrEmpty(_name))
            {
                spec &= new DirectSpecification<PostInfoEntity>(o => o.Name.Contains(_name.Trim()));
            }
            return spec.SatisfiedBy();
        }
    }
}
